package com.auntvt.timo.jpax.core.dialect.exporter;

import org.hibernate.boot.Metadata;
import org.hibernate.dialect.Dialect;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.tool.schema.internal.StandardForeignKeyExporter;

/**
 * 关闭外键生成功能
 *
 * @author 小懒虫 <auntvt@163.com>
 * @date 2021/7/31
 */
public class DisableForeignKeyExporter extends StandardForeignKeyExporter {

    public DisableForeignKeyExporter(Dialect dialect) {
        super(dialect);
    }

    @Override
    public String[] getSqlCreateStrings(ForeignKey foreignKey, Metadata metadata) {
        foreignKey.disableCreation();
        return super.getSqlCreateStrings(foreignKey, metadata);
    }

    @Override
    public String[] getSqlDropStrings(ForeignKey foreignKey, Metadata metadata) {
        foreignKey.disableCreation();
        return super.getSqlDropStrings(foreignKey, metadata);
    }
}
